# Maintainer: Kevin Mihelich <kevin@archlinuxarm.org>
# Maintainer: Dave Higham <pepedog@archlinuxarm.org>

# Trim Slice NVidia HardFP drivers, July 26th release
# Do not distribute these extensively or expect any support

buildarch=4

pkgname=('nvidia-trimslice')
pkgver=16.3.0
pkgrel=2
arch=(armv7h)
license=('GPL')
url="http://archlinuxarm.org"
source=('http://developer.nvidia.com/sites/default/files/akamai/mobile/files/L4T/ventana_Tegra-Linux-R16.3.0_armhf.tbz2'
        'http://developer.nvidia.com/sites/default/files/akamai/mobile/files/L4T/ventana_Tegra-Linux-codecs-R16.3.0_armhf.tbz2'
        'http://developer.nvidia.com/sites/default/files/akamai/mobile/files/L4T/ventana_Tegra-Linux-tegra_drv_abi14-R16.3.0_armhf.tbz2'
        'xorg.conf')
md5sums=('d7153fc89610b9bc7a7c8724e4cc4ef2'
         '029c467589c06c17f3a863d0e1a53325'
         'ebf0018ec16edb5d0d3f15d8fc042ac0'
         '55e50a6894b95795732bdbc942e3e016')

options=('!distcc' '!ccache')

package() {
  pkgdesc="Nvidia drivers for the TrimSlice"
  
  cd ${srcdir}
  tar xf restricted_codecs.tbz2
  tar xf tegra_drv_abi_14.tbz2
  tar xf Linux_for_Tegra/nv_tegra/nvidia_drivers.tbz2
  mv lib/firmware usr/firmware
#  mv usr/lib/libjpeg.so usr/lib/nvlibjpeg.so

  mkdir -p opt/nvidia/
  mv usr/lib/lib* opt/nvidia/

  cd usr/lib/xorg/modules/drivers/
  ln -s tegra_drv.abi14.so tegra_drv.so
  cd ../../../../../
  cp -a usr ${pkgdir}/
  cp -a opt ${pkgdir}/
  mkdir -p ${pkgdir}/etc/X11/
  cp xorg.conf ${pkgdir}/etc/X11/

  mkdir -p ${pkgdir}/usr/bin
  mv ${pkgdir}/usr/sbin/brcm_patchram_plus ${pkgdir}/usr/bin
  rm -rf ${pkgdir}/usr/sbin

  # Create lib links
  mkdir -p "${pkgdir}"/etc/ld.so.conf.d/
 
  # ensure we can load libs
  echo "/opt/nvidia/" > "${pkgdir}"/etc/ld.so.conf.d/nvidia-trimslice.conf
}
